/********************************************************************************
 * CompanyProfileAction.java
 *
 * Created by Jigar Mistry
 * Last modified Date: Sep 29, 2008 4:36:58 PM by Jigar Mistry
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 ********************************************************************************/
package com.printeverywhere.action;

import java.util.List;

import com.printeverywhere.delegator.CommonFunctionDelegator;
import com.printeverywhere.delegator.LocationCategoriesServiceDelegator;
import com.printeverywhere.dto.LocationCategories;
import com.printeverywhere.dto.Options;
import com.printeverywhere.util.AdminConstants;
import com.printeverywhere.util.SearchCriteria;
import com.printeverywhere.util.SearchListCriteria;

import java.io.File;
import java.io.IOException;

import com.printeverywhere.util.FileUtil;
import com.printeverywhere.util.ShellUtil;

public class CompanyProfileAction extends FrontBaseSupport {

	/**  */
	private static final long serialVersionUID = 1L;

	/** The region list. */
	private List<LocationCategories> regionList = getRegionListByLevel();

	private List<Options> businessTypesList = getOptionsById(1);

	private List<Options> noOfEmployeesList = getOptionsById(2);

	private List<Options> registeredCapitalList = getOptionsById(3);

	private List<Options> ownerTypeList = getOptionsById(4);

	private List<Options> annualSalesVolumeList = getOptionsById(5);

	private List<Options> exportPercentageList = getOptionsById(6);

	private List<Options> annualPurchaseVolumeList = getOptionsById(7);

	private List<Options> factorySizeList = getOptionsById(8);

	private List<Options> researchAndDevelopmentStaffList = getOptionsById(9);

	private List<Options> qualityControlStaffList = getOptionsById(10);

	private List<Options> managementCertificationList = getOptionsById(11);

	private List<Options> contractManufacturingList = getOptionsById(12);

	private String homePageUrl;


	public String getHomePageUrl() {
		return homePageUrl;
	}

	public void setHomePageUrl(String homePageUrl) {
		this.homePageUrl = homePageUrl;
	}

	public CompanyProfileAction() {
		super(false, false);
		setMyAccount(true);
	}

	public String execute(){
		return SUCCESS;
	}

	public String createCompanyProfile() {
		setLeftAllowed(false);
		setMyAccount(false);

		return SUCCESS;
	}

	/**
	 * Gets the country list by level.
	 *
	 * @return the country list by level
	 */
	public List<LocationCategories> getRegionListByLevel() {
		SearchListCriteria searchListCriteria = new SearchListCriteria();

		searchListCriteria.setAttribute(AdminConstants.LEVEL, new Object[] {
				AdminConstants.ONE_NUMBER, searchListCriteria.EQ });
		return LocationCategoriesServiceDelegator.getList(searchListCriteria);
	}

	public List<Options> getOptionsById(int id) {
		SearchCriteria searchCriteria = new SearchCriteria();

		searchCriteria.setAttribute("groupId", id);
		return (List<Options>) CommonFunctionDelegator.getObjectBySearchCriteria(searchCriteria, Options.class);
	}

	public List<LocationCategories> getRegionList() {
		return regionList;
	}

	public void setRegionList(List<LocationCategories> regionList) {
		this.regionList = regionList;
	}

	public List<Options> getBusinessTypesList() {
		return businessTypesList;
	}

	public void setBusinessTypesList(List<Options> businessTypesList) {
		this.businessTypesList = businessTypesList;
	}

	public List<Options> getNoOfEmployeesList() {
		return noOfEmployeesList;
	}

	public void setNoOfEmployeesList(List<Options> noOfEmployeesList) {
		this.noOfEmployeesList = noOfEmployeesList;
	}

	public List<Options> getRegisteredCapitalList() {
		return registeredCapitalList;
	}

	public void setRegisteredCapitalList(List<Options> registeredCapitalList) {
		this.registeredCapitalList = registeredCapitalList;
	}

	public List<Options> getOwnerTypeList() {
		return ownerTypeList;
	}

	public void setOwnerTypeList(List<Options> ownerTypeList) {
		this.ownerTypeList = ownerTypeList;
	}

	public List<Options> getAnnualSalesVolumeList() {
		return annualSalesVolumeList;
	}

	public void setAnnualSalesVolumeList(List<Options> annualSalesVolumeList) {
		this.annualSalesVolumeList = annualSalesVolumeList;
	}

	public List<Options> getExportPercentageList() {
		return exportPercentageList;
	}

	public void setExportPercentageList(List<Options> exportPercentageList) {
		this.exportPercentageList = exportPercentageList;
	}

	public List<Options> getAnnualPurchaseVolumeList() {
		return annualPurchaseVolumeList;
	}

	public void setAnnualPurchaseVolumeList(List<Options> annualPurchaseVolumeList) {
		this.annualPurchaseVolumeList = annualPurchaseVolumeList;
	}

	public List<Options> getFactorySizeList() {
		return factorySizeList;
	}

	public void setFactorySizeList(List<Options> factorySizeList) {
		this.factorySizeList = factorySizeList;
	}

	public List<Options> getResearchAndDevelopmentStaffList() {
		return researchAndDevelopmentStaffList;
	}

	public void setResearchAndDevelopmentStaffList(
			List<Options> researchAndDevelopmentStaffList) {
		this.researchAndDevelopmentStaffList = researchAndDevelopmentStaffList;
	}

	public List<Options> getQualityControlStaffList() {
		return qualityControlStaffList;
	}

	public void setQualityControlStaffList(List<Options> qualityControlStaffList) {
		this.qualityControlStaffList = qualityControlStaffList;
	}

	public List<Options> getManagementCertificationList() {
		return managementCertificationList;
	}

	public void setManagementCertificationList(
			List<Options> managementCertificationList) {
		this.managementCertificationList = managementCertificationList;
	}

	public List<Options> getContractManufacturingList() {
		return contractManufacturingList;
	}

	public void setContractManufacturingList(List<Options> contractManufacturingList) {
		this.contractManufacturingList = contractManufacturingList;
	}

	public String addCompanyProfile() {
		/*try{
			File dirPath = new File("C:\\nutch-0.9\\crawl");
			FileUtil.deleteFile(dirPath);
			FileUtil.editFile("C:\\nutch-0.9\\urls\\url.txt", homePageUrl);
			FileUtil.editFileByLocation("C:\\nutch-0.9\\conf\\crawl-urlfilter.txt", homePageUrl);
			ShellUtil.runShellScript("",null);
			ShellUtil.runShellScript("bin/nutch crawl urls -dir crawl -depth 3 -topN 50", null);
		}catch (IOException e) {
			// TODO: handle exception
		}*/

		return SUCCESS;
	}
}
